package com.outsource.framework.model.services.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;

import com.outsource.framework.domain.Tactivity;
import com.outsource.framework.model.QueryParamer;
import com.outsource.framework.model.QueryParamerSpecial;
import com.outsource.framework.model.repository.TactivityRepository;
import com.outsource.framework.model.services.TactivityService;

@Service
public class TactivityServiceImpl implements TactivityService{

	@Autowired
	TactivityRepository repository;

	@Override
	public Tactivity save(Tactivity entity) {
		// TODO Auto-generated method stub
		return repository.save(entity);
	}

	@Override
	public Tactivity getById(Integer id) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void update(Tactivity dto) {
		// TODO Auto-generated method stub
		repository.save(dto);
	}

	@Override
	public List<Tactivity> getByJTAll(String status) {
		// TODO Auto-generated method stub
		return repository.getByJTAll(status);
	}

	@Override
	public List<Tactivity> getByPCAll(List<String> scope,String status) {
		// TODO Auto-generated method stub
		return repository.getByPCAll(scope,status);
	}

	@Override
	public Page<Tactivity> findAll(Pageable pageable) {
		// TODO Auto-generated method stub
		return repository.findAll(pageable);
	}

	@Override
	public Page<Tactivity> findQuery(Map<String, String> map, Pageable pageable) {
		// TODO Auto-generated method stub
		Specification<Tactivity> s = new QueryParamer<Tactivity>(map);
		return this.findAll(s, pageable);
	}

	public Page<Tactivity> findAll(Specification<Tactivity> s,Pageable pageable){
		return repository.findAll(s, pageable);
	}
	
	public Page<Tactivity> findAllin(Map<String, Object> map,Pageable pageable){
		Specification<Tactivity> s = new QueryParamerSpecial<Tactivity>(map);
		return  this.findAll(s,pageable);
	}
}
